//
//  WeatherView.m
//  SportRing
//
//  Created by 微我网络 on 15/1/27.
//  Copyright (c) 2015年 HotOne. All rights reserved.
//

#import "WeatherView.h"

@interface WeatherView ()

@property (nonatomic,strong) UILabel *temperatureLabel;

@property (nonatomic,strong) UILabel *cityLabel;

@property (nonatomic,strong) UILabel *weatherName;

//@property (nonatomic,strong) UIImageView *weatherImage;

@end

@implementation WeatherView

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        _temperatureLabel = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width/2 -100, 3, 120, 60)];
        _temperatureLabel.textAlignment = NSTextAlignmentRight;
        _temperatureLabel.textColor = [UIColor grayColor];
        _temperatureLabel.font = [UIFont fontWithName:@"AppleSDGothicNeo-Thin" size:44];
        [self addSubview:_temperatureLabel];
        
        _cityLabel = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width/2 +25, 10, 80, 20)];
        _cityLabel.textAlignment = NSTextAlignmentLeft;
        _cityLabel.textColor = [UIColor grayColor];
        _cityLabel.font = [UIFont systemFontOfSize:11];
        [self addSubview:_cityLabel];
        
        _weatherName = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width/2 +25, 30, 80, 20)];
        _weatherName.textAlignment = NSTextAlignmentLeft;
        _weatherName.textColor = [UIColor grayColor];
        _weatherName.font = [UIFont systemFontOfSize:11];
        [self addSubview:_weatherName];
        
//        _weatherImage = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width/2+50, 10, 40, 40)];
//        _weatherImage.backgroundColor = [UIColor blackColor];
//        [self addSubview:_weatherImage];
        
//        [self setTemperature:@"0"];
//        [self setCity:@"成都"];
//        [self setWeather:WeatherTypeSunny];
    }
    return self;
}

- (void)setTheWeather:(NSString *)theWeather {
    
    _theWeather = theWeather;
    _weatherName.text = _theWeather;
}

- (void)setTemperature:(NSString *)temperature {
    
    _temperature = temperature;
    if (_temperature.length > 0) {
        _temperatureLabel.text = [NSString stringWithFormat:@"%@°C",_temperature];
    }
    else {
        _temperatureLabel.text = @"";
    }
}

- (void)setCity:(NSString *)city {
    
    _city = city;
    _cityLabel.text = _city;
}

- (void)setWeather:(WeatherType)weather {
    
    NSString *weatherName = @"";
    NSString *weatherPic  = @"";
    switch (weather) {
        case WeatherTypeSunny:
            weatherName = @"晴";
            weatherPic = @"";
            break;
            
        case WeatherTypeRainy:
            weatherName = @"下雨";
            weatherPic = @"";
            break;
            
        case WeatherTypeCloudy:
            weatherName = @"多云";
            weatherPic = @"";
            break;
            
        case WeatherTypeSnowy:
            weatherName = @"小雪";
            weatherPic = @"";
            break;
            
        case WeatherTypeFoggy:
            weatherName = @"大雾";
            weatherPic = @"";
            break;
            
        default:
            break;
    }
    
    _weatherName.text = weatherName;
//    _weatherImage.image = [UIImage imageNamed:weatherPic];
}

//WeatherTypeSunny,
//WeatherTypeRainy,
//WeatherTypeCloudy,
//WeatherTypeSnowy,
//WeatherTypeFoggy

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
